# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>

pkgname=which
pkgver=2.21
pkgrel=2
pkgdesc="A utility to show the full path of commands"
arch=('i686' 'x86_64')
url="http://www.xs4all.nl/~carlo17/which"
license=('GPL3')
groups=('base')
source=("http://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        am-1.14.all.patch
        msys2-allow-windows-mixed-absolute-paths.patch)
depends=('msys2-runtime' 'sh')
makedepends=('msys2-runtime-devel')
install=which.install
#options=('debug' '!strip')
md5sums=('097ff1a324ae02e0a3b0369f07a7544a'
         '9315cae265dd34eaf7aae9a23ac1840e'
         '21a76469eaef2af7755d17ee035086a9')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/am-1.14.all.patch
  patch -p1 -i ${srcdir}/msys2-allow-windows-mixed-absolute-paths.patch
}

build() {
  [[ -d ${srcdir}/build-${CHOST} ]] && rm -rf ${srcdir}/build-${CHOST}
  mkdir ${srcdir}/build-${CHOST} && cd ${srcdir}/build-${CHOST}

  ../${pkgname}-${pkgver}/configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST}

  make
}

package() {
  cd ${srcdir}/build-${CHOST}
  make install DESTDIR=${pkgdir}
}
